﻿using Nuwanda.Common;
using Nuwanda.TfsSpotlight.Commands;
using Nuwanda.TfsSpotlight.Shell.Services.Interfaces;
using Nuwanda.TfsSpotlight.Views.Servers;
using Rhino.Mocks;
using NUnit.Framework;

namespace TfsSpotlight.Tests.Commands
{
    [TestFixture]
    [Author("Bartłomiej Legiędź")]
    public class ConnectCommandTests
    {
        private MockRepository _mocks;
        private IServersPresenter _serversPresenterMock;

        private ICommand _testSubject;

        [SetUp]
        public void SetUp()
        {
            this._mocks = new MockRepository();
            this._serversPresenterMock = this._mocks.DynamicMock<IServersPresenter>();

            this._testSubject = new ConnectCommand(this._serversPresenterMock);
        }

        [Test]
        public void WhenAskedTo_RunCommand_Should_HandleConnect()
        {
            using (this._mocks.Record())
            {
                this._serversPresenterMock.HandleConnectSelected();
            }

            using (this._mocks.Playback())
            {
                this._testSubject.Execute();
            }
        }
    }
}